<template>
	<view class="content">
		<binForm-Plugin ref="qFrom" v-model:modelValue="model" v-model:formInfo="formInfo"></binForm-Plugin>
		<button type="primary" @click="submit('baseForm')">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				model:{
					name:'',
					age:'',
					like:'',
					introduction:'',
					datetimesingle:'',
					city:''
					
				},
				formInfo:[
               {
                 name: "name",
                 label: "姓名",
                 type: "input",
                 required: true,
               },
               {
                 name: "age",
                 label: "年龄",
                 type: "input",
                 required: true,
               },
			   {
			   	name: "sex",
			   	label: "性别",
			   	type: "radio",
			   	multiple: false,
			   	required: true,
			   	options: () => {
			   		return new Promise((resolve, reject) => {
						//模拟ajax
						resolve(
								[
									{
									text: "男",
									value: 1,
								},
								{
									text: "女",
									value: 2,
								}
								]
							);
			   			// getSex().then(res => {
			   			// 	console.log("resres",res.list)
			   			// 	resolve(
			   			// 		res.list
			   			// 	);
			   			// })
			   		});
			   	}
			   },
               {
                 name: "like",
                 label: "爱好",
                 type: "checkbox",
                 options: [
                   {
                     text: "跑步",
                     value: 0,
                   },
                   {
                     text: "游泳",
                     value: 1,
                   },
                   {
                     text: "绘画",
                     value: 2,
                   },
                   {
                     text: "足球",
                     value: 3,
                   },
                   {
                     text: "篮球",
                     value: 4,
                   },
                   {
                     text: "其他",
                     value: 5,
                   },
                 ],
               },
               {
                 name: "introduction",
                 label: "自我介绍",
                 type: "textarea",
                 required: false,
               },
               {
                 name: "datetimesingle",
                 label: "时间",
                 type: "datetime",
                 required: false,
               },
               {
                 name: "city",
                 label: "城市",
                 type: "dataPicker",
                 options: [
                   {
                     text: "北京",
                     value: "10001",
                   },
                   {
                     text: "上海",
                     value: "10002",
                   },
                   {
                     text: "深圳",
                     value: "10004",
                   }
                 ],
               },
             ]
			}
		},
		onLoad() {
     //       this.formInfo= this.getData();
		   // console.log(" this.formInfo", this.formInfo)
		},
		methods: {
           submit(){
			   this.$refs.qFrom.validate()
		   }
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
